home *** CD-ROM | disk | FTP | other *** search
- this.maxFlyS = 1.5;
- this.maxFlyR = 100;
- this.flyA = new Array();
- this.createFly = function()
- {
- var t = this;
- t.attachMovie("fly","f" + t.fd,t.fd);
- var n = t["f" + t.fd];
- n.rad = 30;
- n.ang = random(360);
- n.arriveAng = false;
- n.angDS = 0;
- n.angS = 0;
- var side = random(4);
- if(side == 0)
- {
- n.cx = random(t.stageW);
- n.cy = (- n._height) / 2 - 30;
- }
- else if(side == 1)
- {
- n.cx = 600 + n._width / 2 + 30;
- n.cy = random(t.stageH);
- }
- else if(side == 2)
- {
- n.cx = random(t.stageW);
- n.cy = t.stageH + 15 + n._height / 2 + 30;
- }
- else if(side == 3)
- {
- n.cx = (- n._width) / 2 - 30;
- n.cy = random(t.stageH);
- }
- n._x = n.cx + n.rad * Math.cos(n.ang * t.rc);
- n._y = n.cy + n.rad * Math.sin(n.ang * t.rc);
- n.mx = Math.random() * 1 + 0.1;
- n.my = Math.random() * 1 + 0.1;
- t.flyA.push(n);
- t.addD("f");
- };
- this.moveFly = function()
- {
- var t = this;
- var i = t.flyA.length - 1;
- while(i >= 0)
- {
- var n = t.flyA[i];
- n.cx += n.mx;
- n.cy += n.my;
- n.mx += Math.random() * 0.3 - 0.15;
- n.my += Math.random() * 0.3 - 0.15;
- if(n.mx > t.maxFlyS)
- {
- n.mx = t.maxFlyS;
- }
- else if(n.mx < - t.maxFlyS)
- {
- n.mx = - t.maxFlyS;
- }
- if(n.my > t.maxFlyS)
- {
- n.my = t.maxFlyS;
- }
- else if(n.my < - t.maxFlyS)
- {
- n.my = - t.maxFlyS;
- }
- if(n._x < t.startX)
- {
- n.mx += 0.05;
- }
- else if(n._x > t.stageW)
- {
- n.mx -= 0.05;
- }
- if(n._y < 0)
- {
- n.my += 0.05;
- }
- else if(n._y > t.stageH)
- {
- n.my -= 0.05;
- }
- n.rad += Math.random() * 2 - 1;
- if(n.rad > t.maxFlyR)
- {
- n.rad = t.maxFlyR;
- }
- else if(n.rad < 0)
- {
- n.rad = 0;
- }
- if(Math.abs(n.angS) < 1)
- {
- var dir = random(2);
- if(dir == 0)
- {
- dir = -1;
- }
- n.angDS = (random(10) + 3) * dir;
- n.arriveAng = false;
- }
- if(n.arriveAng == false and Math.abs(n.angDS - n.angS) > 1)
- {
- n.angS += (n.angDS - n.angS) / 10;
- if(Math.abs(n.angDS - n.angS) <= 1)
- {
- n.arriveAng = true;
- }
- }
- else
- {
- n.angS *= 0.9;
- }
- n.ang += n.angS;
- n._x = n.cx + n.rad * Math.cos(n.ang * t.rc);
- n._y = n.cy + n.rad * Math.sin(n.ang * t.rc);
- i--;
- }
- };
-